﻿using HelperLibrary;
using Quartz;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace AVCJobDispatcherWindows.TaskJobEngine
{
    public class TaskJob : IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            string id = context.JobDetail.JobDataMap["id"].ToString();
            JobInfo jobInfo = TaskJobManager.JobList.First(j => j.Id == id);

            return Task.Run(() =>
            {
                try
                {
                    string data = HTTPHelper.HttpGet(jobInfo.ExecuteUrl, null);
                }
                catch(Exception ex)
                {
                    LogHelper.LogErr(new Exception($"地址【{jobInfo.ExecuteUrl}】执行错误：{ex.Message}"));
                }
            });
        }
    }
}
